#include "../tools.h"



class Solution {
public:
    int trap(vector<int>& height)
    {
        int ans = 0;
        int size = height.size();
        for (int i = 1; i < size - 1; i++) {
            int max_left = 0, max_right = 0;
            for (int j = i; j >= 0; j--) { //Search the left part for max bar size
                max_left = max(max_left, height[j]);
            }
            for (int j = i; j < size; j++) { //Search the right part for max bar size
                max_right = max(max_right, height[j]);
            }
            ans += min(max_left, max_right) - height[i];
            cout << i << " " << min(max_left, max_right) - height[i] << endl;
        }
        return ans;
    }
};


int main(int argc, char const *argv[])
{
    Solution sol;

    vector<int> height = {0,1,0,2,1,0,1,3,2,1,2,1};

    auto res = sol.trap(height);
    cout << res << endl;


    return 0;
}
